<script setup name="blogPostCategoryCascader">
import blogPostCategoryApi from '@/api/biz/blogPostCategoryApi'

const allTreeOptions = ref([])
const props = defineProps({
	fieldNames: {
		type: Object
	},
	value: {
		type: String,
		default: ''
	},
	cascaderChange: {
		type: Function
	}
})
const defaultKey = ref([])
onMounted(() => {
	blogPostCategoryApi.blogPostCategoryAllTree().then(res => {
		allTreeOptions.value = res
	});
	defaultKey.value = props.value
})
const clearKey = () => {
	defaultKey.value = "";
}
defineExpose({
	clearKey
})
</script>

<template>
	<a-cascader
		v-model:value="defaultKey"
		:field-names="props.fieldNames"
		:options="allTreeOptions"
		@change="props.cascaderChange"
		changeOnSelect
		placeholder="选择父类"
	/>
</template>

<style scoped>

</style>
